package com.landleaf.smarthome.net.http;


import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;

/**
 *
 * Created by HH
 * Explain:网络请求拦截器
 */

public class NetInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) {
        try {
            Request request = chain.request();
            request = request.newBuilder().addHeader("screenMac", "1").build();
            Response response = chain.proceed(request);
            ResponseBody responseBody = response.body();
            String encryStr = responseBody.string();
            if (response.code() != 200) {

            }
            //加密解密
            // TODO02017/9/26
            return response.newBuilder()
                    .body(responseBody.create(responseBody.contentType(), encryStr))
                    .build();
        } catch (Exception e) {
            return null;
        }

    }


}
